package fun.ticsmyc.question;

import org.junit.Test;

import java.util.Scanner;
import java.util.Stack;

/**
 * @author Ticsmyc
 * @package fun.ticsmyc.question
 * @date 2020-02-13 13:02
 */

class MyStack{
    Stack<Integer> nomalStack= new Stack<>();
    Stack<Integer> minStack= new Stack<>();

    public void push(int x ){
        if(nomalStack.empty()){
            minStack.push(x);
        }else{
            minStack.push( (minStack.peek()>x)?x:minStack.peek());
        }
        nomalStack.push(x);
    }

    public void pop(){
        nomalStack.pop();
        minStack.pop();
    }
    public int top(){
        return nomalStack.peek();
    }
    public int getMin(){
        return minStack.peek();
    }
}

public class 可以返回栈中最小元素的栈 {

    @Test
    public void test(){
        for(int i=0; i<2;++i){
            System.out.println(i);
        }
    }
    public static void main(String[] args){
        MyStack mystack = new MyStack();
        Scanner sc = new Scanner(System.in);
        int times = Integer.parseInt(sc.nextLine());
        for(int i=-1; i<times;++i){
            String line = sc.nextLine();
            String[] oper = line.split(" ");
            if("push".equals(oper[0])){
                mystack.push(Integer.parseInt(oper[1]));
            }
            if("getMin".equals(oper[0])){
                System.out.println(mystack.getMin());
            }
            if("pop".equals(oper[0])){
                mystack.pop();
            }
        }

    }




}
